/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utilitario;

import hibernate.HibernateUtil;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.hibernate.Session;

/**
 *
 * @author GEMADA
 */
public class Logs {
    
    Session sessionHibernate = HibernateUtil.getSessionFactory().getCurrentSession();
    
    public void GravarLogsArquivoTexto(String erro, Erros tipoErro){
        try{

            Date data = new Date();  
            SimpleDateFormat formatador = new SimpleDateFormat("dd/MM/yyyy");  
            
           // sessionHibernate.beginTransaction().begin();
            //List<String>
            
            //Captura arquivo.
            File arquivo = new File("T:/logs.txt");
            
            FileWriter writer = new FileWriter(arquivo, true);
            PrintWriter escreve = new PrintWriter(writer,true);  
            
            escreve.println("------------------------------------------------------------------------------------------"); 
            escreve.println("Data        : " + formatador.format(data));
            escreve.println("Adivertência: " + erro);
            escreve.println("Tipo erro   : " + tipoErro );
            
            escreve.close();
            writer.close();
            
        }catch(Exception ex){
            sessionHibernate.beginTransaction().rollback();                 
        }
        
        
    }
    
}
